package com.bjsc.service.impl;

import com.bjsc.entity.model.PlatformSummary;
import com.bjsc.service.IIndexService;
import com.bjsc.mapper.IndexMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author create by VIC.Huang
 * @date 2018/3/4
 */
@Service
public class IndexService implements IIndexService {
    @Autowired
    private IndexMapper indexMapper;

    private static int ALL = 0;
    private static int MONTH = 1;
    private static int TODAY = 2;

    @Override
    public PlatformSummary getPlatformSummary() {
        PlatformSummary result = new PlatformSummary();
        result.setMonthRecharge(indexMapper.sumRechargeMoney(MONTH))
                .setMonthUser(indexMapper.countRegisterUsers(MONTH))
                .setMonthWithdraw(indexMapper.sumWithdrawMoney(MONTH))
                .setTodayRecharge(indexMapper.sumRechargeMoney(TODAY))
                .setTodayUser(indexMapper.countRegisterUsers(TODAY))
                .setTodayWithdraw(indexMapper.sumWithdrawMoney(TODAY))
                .setTotalRecharge(indexMapper.sumRechargeMoney(ALL))
                .setTotalUser(indexMapper.countRegisterUsers(ALL))
                .setTotalUserAsset(indexMapper.sumUserAsset())
                .setTotalWithdraw(indexMapper.sumWithdrawMoney(ALL));
        return result;
    }
}
